import Config from "../main.config";
import Ajax from "../utils/Ajax";
module.exports = {
    /*
    * 获取教育背景列表
    * */
    getList: async function (createUser) {
        let url = Config.api.educationList;
        let res = await Ajax.request({
            method: "POST",
            url,
            data: {
                createUser
            }
        })
        return res.map(function (item) {
            return {
                id: item.id,
                professionalName: item.professionalName,
                professionalNo: item.professionalNo,
                schoolName: item.schoolName,
                schoolNo: item.schoolNo,
                schooling: item.schooling,
                grade: item.grade.split(";"),
                studentId: item.studentId
            }
        })
    },

    /*
    * 添加教育背景
    * */
    add: async function (data = {}) {
        let url = Config.api.educationAdd;
        return await Ajax.request({
            method: "POST",
            url,
            data: data
        })
    },

    /*
    * 编辑
    * */
    edit: async function (data = {}) {
        let url = Config.api.educationEdit;
        return await Ajax.request({
            method: "POST",
            url,
            data: data
        })
    },

    /*
    * 删除
    * */
    del: async function (id) {
        let url = Config.api.educationDel;
        return await Ajax.request({
            method: "POST",
            url,
            data: {id}
        })
    },

    /*
    * 获取学长专业列表
    * */
    getMajorList: async function (schoolNo) {
        let url = Config.api.educationProfessionList;
        let data = schoolNo ? {schoolNo} : {}
        return await Ajax.request({
            method: "POST",
            url,
            data
        })
    }
}